const router = require('koa-router')()

let url = 'http://172.25.38.252:3000'

//上传商品
router.post('/', function (ctx, next) {
    let data =  ctx.request.body
    ctx.body = {
        msg:'上传成功',
        data:data
    }
})

// 商品类目
router.get('/classli', function (ctx, next) {
    ctx.body = ['类目1','类目2','类目3']
})


// 商品列表
router.get('/li', function (ctx, next) {
    ctx.body =  [
        { title:'首页商品1', price:70, fm:`${url}/goods1.png`},
        { title:'首页商品2', price:45, fm:`${url}/goods2.png`},
        { title:'首页商品3', price:65, fm:`${url}/goods3.png`},
        { title:'首页商品4', price:14, fm:`${url}/goods2.png`}
    ]
})

// 商品详情
router.get('/row/:id', function (ctx, next) {
    ctx.body = '商品信息：'+ctx.params.id
})

// 购物车商品列表
router.get('/catGoods', function (ctx, next){
    ctx.body = [
        { title:'购物车商品1', price:70, number:1, size:'m',fm:`${url}/goods1.png`},
        { title:'购物车商品2', price:45, number:1, size:'m', fm:`${url}/goods2.png`},
        { title:'购物车商品3', price:65, number:1, size:'m',fm:`${url}/goods3.png`},
        { title:'购物车商品4', price:14, number:1, size:'m', fm:`${url}/goods2.png`}
    ]
})


// 添加商品到购物车
router.post('/catOrder', function (ctx,next){
    let data = ctx.request.body    //获取请求提内容
    ctx.body =  {
        msg:'添加到购物车',
        data:data
    }    //
})


//火爆商品
router.get('/goodsA',function (ctx,next){
    ctx.body = [
        { title:'火爆商品1', fm:`${url}/goods1.png`},
        { title:'火爆商品2', fm:`${url}/goods2.png`},
        { title:'火爆商品3', fm:`${url}/goods3.png`},
    ]
})

// 推荐商品
router.get('/goodsB',function (ctx,next){
    ctx.body = [
        { title:'推荐商品1', fm:`${url}/goods1.png`},
        { title:'推荐商品1', fm:`${url}/goods2.png`},
        { title:'推荐商品3', fm:`${url}/goods3.png`},
    ]
})



module.exports = router